<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title>Title</title>
    <style>
        .conter{
            position: relative;
            padding: 50px;
            border: 1px solid red;
            margin: 5px;
        }
        .item{
            cursor: pointer;
            color: #ccc;

        }
    </style>
</head>
<body>

<div>
    <div class="conter">
        <span class="item" flg="1">赞</span>
    </div>
    <div class="conter">
        <span class="item" flg="1">赞</span>
    </div>
    <div class="conter">
        <span class="item" flg="1">赞</span>
    </div>

</div>


<script src="jquery-1.12.4.js"></script>
<script>
    $('.item').click(function () {
        var flg = $(this).attr('flg');
        if(flg == 1){  //根据flg来判断是添加赞还是取消赞
            var color = '#10c70f';
            var text = '+1';
            $(this).css('color',color).attr('flg',2);
             changeFavor(this,color,text);
        }else if(flg == 2){
            var color = '#ccc';
            var text = '-1';
            $(this).css('color',color).attr('flg',1);
            changeFavor(this,color,text);
        }

    });
    function changeFavor(self,color,text) {
        var fontSize = 15;
        var top = 50;
        var left = 65 ;
        var opacity = 1;
        var newTag = document.createElement('span');
        $(newTag).text(text);
        $(newTag).css('color',color);
        $(newTag).css('position','absolute');
        $(newTag).css('fontSize',fontSize + 'px');
        $(self).append(newTag);

        var obj = setInterval(function () {  //设置定时器
            fontSize = fontSize + 5;
            top = top - 5;
            left = left + 5;
            opacity = opacity - 0.1;
            $(newTag).css('fontSize',fontSize + 'px');
            $(newTag).css('top',top + 'px');
            $(newTag).css('left',left + 'px');
            $(newTag).css('opacity',opacity);
            if (opacity <0){
                clearInterval(obj);  //取消定时器
                $(newTag).remove();
            }
        },100);

    }

</script>

</body>
</html>